program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils;
const
  N=10;
var
  i, j: integer;
  max, nor: integer;
  mass: array of integer;

begin
  randomize;
  setlength(mass, N);
  for i:= 0 to N-1 do
    mass[i]:=random(50);
  max:=0;
  for i:= 0 to N-2 do
  begin
    for j:=0 to N-i-1 do
    begin
       if (mass[j]>=max) then
      begin
        max:=mass[j];
        nor:=j;
      end;
    end;
    mass[nor]:=mass[N-i-1];
    mass[N-i-1]:=max;
    max:=0;
  end;
  for i:=0 to N-1 do
    write(mass[i], '  ');
  readln;
end.
